package com.github.sbb.sherry.primitives.rules.jexl;

import com.github.sbb.sherry.primitives.api.Rule;
import com.github.sbb.sherry.primitives.core.RuleDefinition;
import java.util.Objects;


public class JexlRuleFactory {

    public static Rule createSimpleRule(RuleDefinition ruleDefinition) {
        Objects.requireNonNull(ruleDefinition, "ruleDefinition cannot be null");
        return new JexlRule(ruleDefinition.getName())
            .priority(ruleDefinition.getPriority())
            .condition(ruleDefinition.getCondition())
            .action(ruleDefinition.getAction());
    }
}
